package com.byxy.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.byxy.entity.User;
import com.byxy.service.UserService;
@Controller
public class UserController {
	@Autowired private UserService userService;
	@RequestMapping(value="/login",method=RequestMethod.GET)
	public String a(HttpServletRequest r) {
		return "login";
	}
	@RequestMapping(value="/login",method=RequestMethod.POST)
	public String a(User u,HttpServletRequest r) {
		User user=userService.login(u);
		if(user!=null) {
			r.getSession().setAttribute("user", user);
			return "index";
		};
		return "login";
	}
	@RequestMapping(value="/index",method=RequestMethod.GET)
	public String b(HttpServletRequest r) {
		return "index";
	}
}
